<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <!-- START 右侧数据 -->

            <!-- START 操作按钮 -->
            <form>
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 新增部门权限</a>
            </div>
            </form>
            <!-- END 操作按钮 -->

            <!-- START 数据表格 -->
            <table id="relatedTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-page-size="15"
                   data-url="/sea/human/performanceCheck/findByCnd.do"
                   class="table table-striped ta+ble-hover">
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,layui,upload'}){}%>
<script>


    var $relatedTable = $('#relatedTable'),selections=[];
    $(function(){
        //指定允许上传的文件类型
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: '部门',
                    field: 'performanceGroup',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '审核人',
                    field: 'performanceCheck',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '创建时间',
                    field: 'createTime',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                $('.edit-btn').on('click',function(){//新增
                    var id=$(this).attr("data-val");
                    layer.open({
                        type: 2,
                        area: ['800px','400px'],
                        skin: 'layer-ext-espresso',
                        content: ['/sea/human/performanceCheck/editPage.do?id='+id, 'yes']
                    });
                });

                $('.del-btn').on('click',function(){
                    var delid = $(this).attr('data-val'),delname = $(this).attr('data-val-name');
                    layer.confirm('确定要删除当前？', {
                        btn: ['确定','取消'],title:'提示'
                    }, function(){
                        var index = layer.load();
                        $.post('/sea/human/performanceCheck/delete.do',{id: delid},function(data){
                            if( data.ok ){
                                layer.close(index);
                                layer.msg(data.msg,{icon: 1,time: 1500},function(){
                                    //刷新页面
                                    $relatedTable.bootstrapTable('refresh');
                                });
                            }else{
                                layer.msg(data.msg,{icon: 0,time: 1500});
                                layer.close(index);
                            }
                        });
                    });
                });

            },
            onExpandRow: function (index, row, $detail) {
                InitSubTable(index, row, $detail);
            }
        });
    });
    //操作菜单
    function optFormatter(value,row){
        var content = '<button class="edit-btn btn btn-xs btn-info" data-val="' + row.id + '" title="修改"><i class="fa fa-edit"></i> 修改绩效</button>';
        content += '&nbsp;<button class="del-btn btn btn-xs btn-danger" data-val="'+row.id+'" title="删除"><i class="fa fa-trash-o"></i> 删除</button>';
        return content;
    }
    $('.add-btn').on('click',function(){//新增
        layer.open({
            type: 2,
            area: ['800px','400px'],
            skin: 'layer-ext-espresso',
            content: ['/sea/human/performanceCheck/addPage.do', 'yes']
        });
    });



    //提交表单
    $('#save-btn').on('click',function(){
        layer.confirm('确定要新增绩效？', {
            btn: ['确定','取消'],title:'提示'
        }, function(){

            layer.closeAll();
            var index=layer.load();
            $.post('/sea/human/performance/save.do',function(data){
                if( data.ok ){
                    $relatedTable.bootstrapTable('refresh');
                    layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }else{
                    layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }
            });
        });
    });




    $('.search-btn').on('click',function(){
           $relatedTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/operate/related/findByCnd.do?'+$('#search-form').serialize() });
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/operate/related/export.do?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
